# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=networkmap
pkgver=58.f5faf17
pkgrel=4
groups=('blackarch' 'blackarch-networking' 'blackarch-misc')
pkgdesc='Post-exploitation network mapper.'
arch=('any')
url='https://github.com/lorenzog/NetworkMap'
license=('GPL3')
depends=('python2' 'python2-decorator' 'python2-networkx' 'python2-pydotplus'
         'python2-pyparsing' 'python2-nose' 'python2-ipaddress')
makedepends=('git')
source=("$pkgname::git+https://github.com/lorenzog/NetworkMap.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md
  install -Dm 644 license.txt "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  rm README.md license.txt

  cp -a * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname/$pkgname
exec python2 __main__.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

